<%--                                                                       --%>
<%-- Copyright (c) 2004-2005 BroadVision, Inc.  All rights reserved.       --%>
<%--                                                                       --%>
<%-- This software is copyrighted. Under the copyright laws, this software --%>
<%-- may not be copied, in whole or in part, without prior written consent --%>
<%-- of BroadVision, Inc. or its assignees. This software is provided      --%>
<%-- under the terms of a license between BroadVision and the recipient,   --%>
<%-- and its use is subject to the terms of that license.                  --%>
<%--                                                                       --%>
<%-- This software may be protected by one or more U.S. and International  --%>
<%-- patents.  Certain applications of BroadVision One-To-One software are --%>
<%-- covered by U.S. patent 5,710,887.                                     --%>
<%--                                                                       --%>
<%-- TRADEMARKS: BroadVision and BroadVision One-To-One are registered     --%>
<%-- trademarks of BroadVision, Inc., in the United States and the         --%>
<%-- European Community, and are trademarks of BroadVision, Inc., in other --%>
<%-- countries.  The BroadVision logo, is a trademark of BroadVision,      --%>
<%-- Inc., in the United States and other countries. Additionally, IONA    --%>
<%-- and Orbix are trademarks of IONA Technologies, Ltd.  RSA, MD5, and    --%>
<%-- RC2 are trademarks of RSA Data Security, Inc.                         --%>
<%--                                                                       --%>

<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>

<script language="JavaScript">

  // Trim whitespace from left and right sides of s.
  function trim(s) {
    return s.replace( /^\s*/, "" ).replace( /\s*$/, "" );
  }

//
// Trims leading blanks.
//
function stringLeftTrim(s) {
  return s.replace(/^ +/, "");
}

//
// Trims trailing blanks.
//
function stringRightTrim(s) {
  return s.replace(/ +$/, "");
}

//
// Trims leading and trailing blanks.
//
function stringTrim(s) {
  return stringRightTrim(stringLeftTrim(s));
}

//
// Create a dummy (timestamp) attribute to get around an IE cache problem.
//
function getTimeStamp() {
   var now = new Date;
   var timestamp = '' + now.getYear() + now.getMonth() + now.getDate() + now.getHours() + now.getMinutes() + now.getSeconds() + now.getMilliseconds();
   return timestamp;
}


function searchUserPopup(popupUrl, parentFormName, parentFieldName) {
  var thisForm = document.forms[parentFormName];
  var windowName = parentFormName + parentFieldName;
  var windowFeatures = 'width=700,height=600,scrollbars=yes,resizable=yes';
  var urlDummy="<%=request.getContextPath()%>"+"/mt/user/userPopupHelper.jsp?parentFormName="+parentFormName+"&parentFieldName="+parentFieldName;
  var popupWindow=window.open(urlDummy,windowName,windowFeatures);
  if ( popupWindow != null) {
    if( popupWindow.opener == null) {
      popupWindow.opener = self;
    }
  }
  popupWindow.focus();
}

function setUserAliasNew(formName, fieldValue, firstName, lastName,
fullName, userAlias) {
  // this page does not have any hidden fields that rely on the popup,
  // we do not need a refresh url.
  var refreshUrl = null;
  setUserFindFieldValue(refreshUrl, formName, fieldValue, firstName,
lastName, fullName, userAlias);
}
  
function setUserFindFieldValue(refreshUrl, formName, fieldValue,
firstName, lastName, fullName, userAlias) {

  var thisForm = document.forms[formName];
  var elements = thisForm.elements;
  var numElements = elements.length;

  if (thisForm.useFullName.value == "true") {
    thisForm.fullNameFrom.value = fullName;
  }
  else {
    thisForm.firstNameFrom.value = firstName;
    thisForm.lastNameFrom.value = lastName;
  }
  thisForm.userAliasFrom.value = userAlias;
}

function isFormCancelOK(theForm) {
    //var ok = confirm('<bean:message key="confirmCancel"  bundle="bp.messages"/>');
    var ok = true;
    if (ok && theForm != null) {
      theForm.action='<html:rewrite page="/bp/userSearch.do" />';
      theForm.submit();
    }
    return ok ;
}

  function doNext(theForm) {
    if (theForm.useFullName.value == "true") {
      if ((trim(theForm.fullNameFrom.value).length == 0) &&
	(trim(theForm.userAliasFrom.value).length == 0)) {
        alert('<bean:message key="bp.user.reassignTasks.userFrom.empty"  bundle="bp.messages"/>');
        return false;
      }
    }
    else {
      if (
          ((trim(theForm.firstNameFrom.value).length == 0) &&
	   (trim(theForm.lastNameFrom.value).length == 0) &&
	   (trim(theForm.userAliasFrom.value).length == 0))) {
        alert('<bean:message key="bp.user.reassignTasks.userFrom.empty"  bundle="bp.messages"/>');
        return false;
      }
    }
    return true;
  }

</script>


<% 
  java.util.HashMap map = new java.util.HashMap();
  String userId = request.getParameter("userId"); 

  map.put("userId", userId);
  map.put("firstNameFrom", request.getParameter("firstNameFrom"));
  map.put("lastNameFrom", request.getParameter("lastNameFrom"));
  map.put("fullNameFrom", request.getParameter("fullNameFrom"));
  map.put("userAliasFrom", request.getParameter("userAliasFrom"));

  pageContext.setAttribute("pagetabParam", map, PageContext.PAGE_SCOPE);
%>

<html:form action="/bp/reassignTasksFrom.do">

<html:hidden property="useFullName" />
<html:hidden property="firstNameTo" />
<html:hidden property="lastNameTo" />
<html:hidden property="fullNameTo" />
<html:hidden property="userAliasTo" />
<html:hidden property="userId"/>
<html:hidden property="formAction" value="select"/>

<!-- Zone 5 starts here.  -->

<table class="zoneFive" width="100%" border="0" cellspacing="0" cellpadding="0" summary="<bean:message key="bp.package.contentArea" bundle="bp.messages"/>">
  <tr>
    <td valign="top" width="100%">		    

      <div class="pageTitle">
          <bean:message key="bp.user.reassignTasks" bundle="bp.messages"/>
      </div>

      <!-- pageTab -->
      <div class="errorMessage"><html:errors bundle="bp.messages" /></div>
      <%@include file="/mc/common/pagetab.jsp" %>
      <!-- end of PageTab -->			

      <div class="pageSubtitle">
        <span class="left">
          <bean:message key="bp.user.reassignTasks.selectFrom" bundle="bp.messages"/>
        </span>
        <span class="right">&nbsp;</span>
      </div> 

      <table class="labelForm" width="100%" border="0" cellspacing="0" cellpadding="0" summary="Select ??">
        <tr> 
          <td class="label" width="10%" nowrap><bean:message key="bp.user.reassignTasks.from" bundle="bp.messages"/>:</td>

          <logic:equal name="reassignTasksForm" property="useFullName" value="false">
            <td class="labelField" width="10%" nowrap>
              <html:text name="reassignTasksForm" property="firstNameFrom" size="20" maxlength="100" />
                <br><i>(<bean:message key="bp.user.label.firstName" bundle="bp.messages"/>)</i>
            </td>
            <td class="labelField" width="10%" nowrap>
	      <html:text name="reassignTasksForm" property="lastNameFrom" size="20" maxlength="100" />
              <br><i>(<bean:message key="bp.user.label.lastName" bundle="bp.messages"/>)</i> 
            </td>
          </logic:equal>
          
          <logic:equal name="reassignTasksForm" property="useFullName" value="true">
            <td class="labelField" width="20%" nowrap>
	      <html:text name="reassignTasksForm" property="fullNameFrom" size="20" maxlength="50" />
              <br><i>(<bean:message key="bp.user.label.fullName" bundle="bp.messages"/>)</i>
            </td>
          </logic:equal>

          <td class="labelField" width="10%" nowrap>
	      <html:text name="reassignTasksForm" property="userAliasFrom" size="20" maxlength="255" />
              <br><i>(<bean:message key="bp.user.label.loginId" bundle="bp.messages"/>)</i>
          </td>
          <td class="labelField" width="60%" nowrap>
            <input type="button" name="browse" class="pageButton"
              onclick="JavaScript:searchUserPopup('<html:rewrite page="/mt/userSearchPopup.do"/>', 'reassignTasksForm','from');" value='<bean:message key="button.browse" bundle="bp.messages"/>'>
          </td>
        </tr>
      </table>

      <div class="pageButtonWrap" align="right">
        <html:button styleClass="pageButton" property="cancelBtn" onclick="bCancel=true; return isFormCancelOK(this.form)">
            <bean:message key="button.cancel" bundle="bp.messages"/>
        </html:button>

        <html:submit styleClass="pageButton" property="submitBtn" onclick="return doNext(this.form)" >
           <bean:message key="button.next" bundle="bp.messages"/>
        </html:submit>
      </div>
			
    </td>
  </tr>
</table>

<!--end zone 5 content here -->

</html:form> 
